var a = getApp();

Page({
    data: {
        active: 0,
        list: [],
        info: [],
        quota: 0,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(a) {
        wx.setNavigationBarTitle({
            title: "个人额度"
        });
    },
    onReady: function() {},
    onShow: function() {
        this.getData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    getData: function() {
        var t = this;
        wx.showLoading({
            title: "加载中"
        });
        a._getNetWork({
            url: a.getNetAddresss("plugin.activity-ranking.frontend.quota.personal-quota"),
            data: {
                page: this.data.page
            },
            success: function(a) {
                if (wx.hideLoading({
                    success: function(a) {}
                }), 1 == a.data.result) {
                    var e = a.data.data;
                    t.setData({
                        isLoadMore: !0,
                        total_page: e.list.last_page,
                        quota: e.quota,
                        list: e.list.data
                    }), t.data.total_page || (t.data.total_page = 0);
                } else t.setData({
                    page: t.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        wx.showLoading({
            title: "加载中"
        });
        if (this.data.page >= this.data.total_page) return this.setData({
            isLoadMore: !1
        }), void wx.hideLoading({
            success: function(a) {}
        });
        this.setData({
            page: this.data.page + 1
        }), a._getNetWork({
            url: a.getNetAddresss("plugin.activity-ranking.frontend.quota.personal-quota"),
            data: {
                page: this.data.page
            },
            success: function(a) {
                if (wx.hideLoading({
                    success: function(a) {}
                }), 1 == a.data.result) {
                    var e = a.data.data;
                    t.setData({
                        isLoadMore: !0,
                        list: t.data.list.concat(e.list.data)
                    });
                } else t.setData({
                    page: t.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(a) {
                wx.hideLoading({
                    success: function(a) {}
                }), console.log(a);
            }
        });
    }
});